package com.ruoyi.web.controller.common;

import java.util.HashMap;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysDictTypeService;

@RestController
@RequestMapping("/system/common/enum")
public class EnumController {


    @Autowired
    private ISysDictTypeService dictTypeService;


    private static final Logger log = LoggerFactory.getLogger(EnumController.class);

    @PostMapping
    public AjaxResult queryByEnumType(@RequestBody String[] enumType) {
        if (StringUtils.isNotEmpty(enumType)) {

            HashMap<String, List<SysDictData>> result = new HashMap<String, List<SysDictData>>();
            List<SysDictData> datas = null;
            for (String type : enumType) {
                datas = dictTypeService.selectDictDataByType(type.replace("dict.", ""));
                result.put(StringUtils.toCamelCase(type), datas);
            }

            return AjaxResult.success(result);
        }
        return AjaxResult.success();
    }

}
